<template>
	<view>
		<baseForm :column.sync="column" @submitFun="submitFun" :submitStatus="submitDisable" :button="button"></baseForm>
		<view style="margin-top: 20upx; padding: 0 50upx;" v-if="!itemData.lessonCondition">
			<button class="loginBtn" @click="finishCheck">完成</button>
		</view>
	</view>
</template>

<script>
import baseForm from '@/wxcomponents/form/form.vue';
import formMixins from '@/libs/formMixins.js'
export default {
	mixins: [formMixins],
	data() {
		return {
			itemData: '',
			auditVos: '',
			button: {
				hide: true
			},
			column: [
				{
					label: '授课教师',
					name: 'teacherName',
					type: 'normalInput',
					disabled: true,
					required: false,
					value: ''
				},
				{
					label: '课程名称',
					name: 'courseName',
					type: 'normalInput',
					disabled: true,
					required: false,
					value: '',
					text: '',
				},
				{
					label: '任教班级',
					name: 'className',
					type: 'normalInput',
					disabled: true,
					required: false,
					value: '',
					text: '',
				},
				{
					label: '授课日期',
					name: 'lessonDate',
					type: 'normalInput',
					disabled: true,
					required: false,
					value: '',
					text: '',
				},
				{
					label: '授课节次',
					name: 'lessonSection',
					type: 'normalInput',
					disabled: true,
					required: false,
					value: '',
					text: '',
				},
				{
					label: '课堂情况',
					name: 'lessonCondition',
					type: 'textarea',
					disabled: false,
					required: true,
					value: 1,
					text: '请填写',
				},
			],
		};
	},
	async onLoad(option) {
		this.itemData = JSON.parse(option.data);
		debugger
		this.getDetail();
		
	},
	methods: {
		async getDetail() {
			let self = this;
			self.assignFormDataToViewModel(this.itemData, self.column);
			if (this.itemData.lessonCondition) {	// 已填写，禁用课堂情况
			debugger
				this.column[5].disabled = true;
				this.column[5].value = this.itemData.lessonCondition;
			debugger	
			}
		},
		async finishCheck() {
			if (!this.column[5].value) {
				uni.showToast({
					title: '请填写课堂情况',
					icon: 'none',
					duration: 1000,
				});
				return;
			}
			let resp = await this.$http.post({
				url: '/edu/schoolJournal/save',
				data: {
					id: this.itemData.id,
					lessonCondition: this.column[5].value?this.column[5].value:''
				}
			}); 
			uni.showToast({
				title: '提交成功',
				icon: 'none',
				duration: 1000,
			});
			setTimeout(() => {
				uni.navigateBack();
			}, 1000)
		}
	},
	components: {
		baseForm,
	},
	watch: {}
};
</script>

<style></style>
